<template>
  <div class="banner-container">
    <el-carousel 
      height="420px"
      :interval="5000"
      indicator-position="none"
      arrow="hover"
    >
      <el-carousel-item v-for="item in banners" :key="item.id">
        <div class="banner-content">
          <img 
            :src="item.image" 
            :alt="item.title" 
            class="banner-image"
          />
          <div class="banner-text">
            <h3 class="banner-title">{{ item.title }}</h3>
            <p class="banner-desc" v-if="item.desc">{{ item.desc }}</p>
          </div>
        </div>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const banners = ref([
  {
    id: 1,
    image: '/shopimgs/lunbo/lun1.png',
    title: '春季大促销',
    desc: '全场商品5折起，限时优惠'
  },
  {
    id: 2,
    image: '/shopimgs/lunbo/lun2.png',
    title: '新品上市',
    desc: '最新款式，抢先体验'
  },
  {
    id: 3,
    image: '/shopimgs/lunbo/lun3.png',
    title: '限时抢购',
    desc: '每日10点准时开抢'
  }
])
</script>

<style scoped>
.banner-container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.banner-content {
  position: relative;
  width: 100%;
  height: 100%;
}

.banner-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.banner-text {
  position: absolute;
  bottom: 50px;
  left: 40px;
  color: white;
  max-width: 60%;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.banner-title {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.banner-desc {
  font-size: 1rem;
  margin: 0;
  opacity: 0.9;
}

/* 稳定不跳动的箭头 */
:deep(.el-carousel__arrow) {
  background: rgba(0,0,0,0.3) !important;
  color: white !important;
  width: 42px !important;
  height: 42px !important;
  font-size: 20px !important;
  border: none !important;
  opacity: 0 !important;
  transition: all 0.2s ease !important;
  border-radius: 50% !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  margin: 0 !important;
}

:deep(.el-carousel:hover .el-carousel__arrow) {
  opacity: 1 !important;
}

:deep(.el-carousel__arrow:hover) {
  background: rgba(0,0,0,0.5) !important;
  transform: translateY(-50%) scale(1.05) !important;
}

:deep(.el-carousel__arrow--left) {
  left: 20px !important;
}

:deep(.el-carousel__arrow--right) {
  right: 20px !important;
}

@media (max-width: 768px) {
  .banner-text {
    bottom: 30px;
    left: 20px;
    max-width: 80%;
  }
  
  .banner-title {
    font-size: 1.4rem;
  }
  
  .banner-desc {
    font-size: 0.9rem;
  }
}
</style>